package schoolword3;

import java.util.Objects;

class Point{
    private int x;  // 横坐标
    private int y;   //纵坐标

    public Point() {
    }

    public Point(int x, int y) {
        this.x = x;
        this.y = y;
    }

    public int getX() {
        return x;
    }

    public void setX(int x) {
        this.x = x;
    }

    public int getY() {
        return y;
    }

    public void setY(int y) {
        this.y = y;
    }


}

class Circle extends Point {
    private float radius;
    final float PI = 3.14f;

    public Circle() {
    }

    public Circle( int x, int y,float radius) {
        super(x,y);
        this.radius = radius;
    }

    public float getRadius() {
        return radius;
    }

    public void setRadius(float radius) {
        this.radius = radius;
    }

    public float getArea() {
        return PI * radius * radius;
    }

    public float getPerimeter() {
        return 2 * PI * radius;
    }

    //重写toString方法  返回圆的信息

    @Override
    public String toString() {
        return "圆点(" + getX() + "," + getY() + "), 半径: " + radius + ", 周长: " + getPerimeter() + ", 面积: " + getArea();
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Circle circle = (Circle) o;
       // return Float.compare(radius, circle.radius) == 0;
        return radius == circle.radius;
    }

    @Override
    public int hashCode() {
        return (int) radius;
    }
}
public class InheritText {
    public static void main(String[] args) {
        Circle c1 = new Circle(10,25,5.5f);
        System.out.println(c1.toString());

        Circle c2 = new Circle(10,25,5.5f);
        System.out.println(c2.equals(c1));
        System.out.println(c2.hashCode());
    }
}
